{% extends 'base.html' %}
{% block title %} 课程机构列表 {% endblock %}

{% block content %}
<section>
	<div class="wp butler_list_box list">
	<div class='left'>
		<div class="listoptions">
			<ul>
				<li>
					<h2>机构类别</h2>
					<div class="cont">
                        <a href="?city="><span class="active2">全部</span></a>

                            <a href="?ct=pxjg&city = {{ cityid }}"><span class="{% ifequal pxjg category %}active2{% endifequal %}">培训机构</span></a>

                            <a href="?ct=gx&city = {{ cityid }}"><span class="{% ifequal gx category %}active2{% endifequal %}">高校</span></a>

                            <a href="?ct=gr&city = {{ cityid }}"><span class="{% ifequal gr category %}active2{% endifequal %}">个人</span></a>

					</div>
				</li>
				<li>
					<h2>所在地区</h2>
					<div class="more">更多</div>
					<div class="cont">
                        <a href="?ct="><span class="active2">全部</span></a>
                        {% for city in all_citys %}
                            <a href="?city={{ city.id}}&ct={{ category }}"><span class = "{% ifequal city.id|stringformat:"i" cityid %}active2{% endifequal %}" >{{ city.name }}</span></a>
                        {% endfor %}
					</div>
				</li>
			</ul>
		</div>
		<div class="all">共<span class="key">{{ org_nums }}</span>家</div>
		<div class="butler_list company list">
		<div class="layout">
			<div class="head">
				<ul class="tab_header">
					<li class="active"><a href="?ct=&city=">全部</a> </li>
					<li class=""><a href="?sort=students&ct=&city=">学习人数 &#8595;</a></li>
					<li class=""><a href="?sort=courses&ct=&city=">课程数 &#8595;</a></li>
				</ul>
			</div>

            {% for course_org in org_lists.object_list %}
                <dl class="des difdes">
                    <dt>
                        <a href="org-detail-homepage.html">
                            <img width="200" height="120" class="scrollLoading" data-url="{{ MEDIA_URL }}{{ course_org.images }}"/>
                        </a>
                    </dt>
                    <dd>
                        <div class="clearfix">
                             <a href="org-detail-homepage.html">
                                 <h1>{{ course_org.name }}</h1>
                                 <div class="pic fl">

                                         <img src="../images/authentication.png"/>

                                         <img src="../images/gold.png"/>

                                 </div>
                             </a>
                        </div>
                        <ul class="cont">
                            <li class="first"><p class="pic9">课程数：<span>1</span></p><p class="c7">学习人数：<span>1000</span></p></li>
                            <li class="c8" style="padding-left:18px;">{{ course_org.address }}</li>
                            <li class="pic10" style="padding-left:18px;">经典课程：

                                    <a href="/diary/19/">c语言基础入门</a>

                                    <a href="/diary/16/">数据库基础</a>

                            </li>
                        </ul>
                    </dd>
                    <div class="buy start_groupbuy jsShowPerfect2" data-id="22"><br/>联系<br/>服务</div>
                </dl>
            {% endfor %}

		</div>

		 <div class="pageturn">
            <ul class="pagelist">
            {#分页的设置，对所有的page_obj都替换为我们自己的分页对象#}
            {# 对前一页的设置#}
                {% if org_lists.has_previous %}
                    {# 如果有前一页，且需要显示，则显示前一页#}
                    <li class="long"><a href="?{{ org_lists.previous_page_number.querystring }}">上一页</a></li>
                {% else %}
                    {#如果没有前一页,不要显示,则显示为空#}
                {% endif %}
                    {#循环数据#}
                    {% for page in org_lists.pages %}
                        {% if page %}
                            {% ifequal page org_lists.number %}
                            {# 如果是当前页#}
                                <li class="active"><a href="?page=1">{{ page }}</a></li>
                            {% else %}
                            {#如果不是当前页#}
                                <li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
                            {% endifequal %}
                        {% else %}
                            {#显示...#}
                             <li class="none"><a href="">...</a></li>
                        {% endif %}
                    {% endfor %}
                    {#显示后一页#}
                    {% if org_lists.has_next %}
                        {#如果需要显示后一页#}
                        <li class="long"><a href="?{{ org_lists.next_page_number.querystring }}">下一页</a></li>
                    {% else %}
                        {#如果不需要显示后一页#}
                    {% endif %}
            </ul>
        </div>
		</div>
	</div>
	<div class="right companyright">
			<div class="head">我要学习</div>
			<form class="rightform" id="jsStayForm">
				<div>
                    <img src="../images/rightform1.png"/>
                    <input type="text" name="name" id="companyName" placeholder="名字" maxlength="25" />
                </div>
				<div>
                    <img src="../images/rightform2.png"/>
                    <input type="text" name="mobile" id="companyMobile" placeholder="联系电话"/>
                </div>
				<div>
                    <img src="../images/rightform3.png"/>
                    <input type="text" name="course_name" id="companyAddress" placeholder="课程名" maxlength="50" />
                </div>
                <p class="error company-tips" id="jsCompanyTips"></p>
				<input class="btn" type="text" id="jsStayBtn" value="立即咨询" />
                {% csrf_token %}
            </form>
		</div>

		<div class="right companyrank layout">
			<div class="head">授课机构排名</div>


                <dl class="des">
                    <dt class="num fl">1</dt>
                    <dd>
                        <a href="/company/2/"><h1>慕课网</h1></a>
                        <p>北京市</p>
                    </dd>
                </dl>

                <dl class="des">
                    <dt class="num fl">2</dt>
                    <dd>
                        <a href="/company/2/"><h1>慕课网2</h1></a>
                        <p>深圳市</p>
                    </dd>
                </dl>

                <dl class="des">
                    <dt class="num fl">3</dt>
                    <dd>
                        <a href="/company/2/"><h1>北京大学</h1></a>
                        <p>北京市</p>
                    </dd>
                </dl>




		</div>
        </div>
</section>
{% endblock %}

{% block user_ask_js %}
    <script>
    $(function(){
        $(document).ready(function() {
            $('#jsStayBtn').on('click', function () {
                $.ajax({
                    cache: false,
                    type: "POST",
                    url: "/org/add_ask/",
                    data: $('#jsStayForm').serialize(),
                    async: true,
                    success:function(data) {
                        console.log(data);
                        if (data.status == 'success') {
                            $('#jsStayForm')[0].reset();
                            alert("提交成功")
                        } else if (data.status == 'fail') {
                            $('#jsCompanyTips').html(data.msg)
                        }
                    },
                });
            });
        });
    })
</script>
{% endblock %}